package vendingMachine;

public class Strike {
	
	// 
	public static boolean isStrike(int id) {
		if(getRandomNumber() > 5) {
			// はずれ
			return false;
		} else {
			// あたり
			if(Util.getZaiko(id) > 0){
				return false;
			} else {
				// IDごとに
				if(id == 1) {
					JuiceConstants.TOTAL_STRIKE_COLA++;
					JuiceConstants.TOTAL_STRIKE_PRICE_COLA += JuiceConstants.PRICE_COLA;
				} else if(id == 2) {
					JuiceConstants.TOTAL_STRIKE_REDBULL++;
					JuiceConstants.TOTAL_STRIKE_PRICE_REDBULL += JuiceConstants.PRICE_REDBULL;
				} else if(id == 3) {
					JuiceConstants.TOTAL_STRIKE_WATER++;
					JuiceConstants.TOTAL_STRIKE_PRICE_WATER += JuiceConstants.PRICE_WATER;
				}
				JuiceConstants.TOTAL_STRIKE_PRICE += JuiceConstants.TOTAL_STRIKE_PRICE_COLA;
				JuiceConstants.TOTAL_STRIKE_PRICE += JuiceConstants.TOTAL_STRIKE_PRICE_REDBULL;
				JuiceConstants.TOTAL_STRIKE_PRICE += JuiceConstants.TOTAL_STRIKE_PRICE_WATER;
				return true;
			}
		}
	}
	
	/**
	 *  1-100のランダムな数値の返却を行う
	 */
	public static int getRandomNumber() {
		int res = 0;
		res = (int)Math.floor(Math.random() * (100-1+1))+1;
		return res;
	}
}
